package com.example.springboot_demo.controller;

import com.example.springboot_demo.pojo.mongoUser;
import com.example.springboot_demo.service.mongoUserService;
import com.example.springboot_demo.order.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 江岸
 * @version V1.0
 * @ClassName: mongoUserController
 * @description: mongoDB的增删改查demo
 * @date 2020/8/511:24
 * @since V1.0
 */
@RestController
@RequestMapping("/mongo")
public class mongoUserController {
    @Autowired
    private mongoUserService mongoUserService;

    /**
     * @Description: <br>
     * 〈添加一条数据〉
     * @Param: [user]
     * @Return: void
     * @Author: 江岸
     * @Date: 2020/8/5 14:09
     */
    @RequestMapping("/add")
    public void insert(@RequestBody mongoUser user) {
        mongoUserService.insert(user);
    }

    /**
     * @Description: <br>
     * 〈查询所有数据〉
     * @Param: []
     * @Return: java.util.List<com.example.springboot_demo.pojo.mongoUser>
     * @Author: 江岸
     * @Date: 2020/8/5 14:23
     */
    @RequestMapping("/findAll")
    public List<mongoUser> findAll(){
        List<mongoUser> all = mongoUserService.findAll();
        return all;
    }
}
